package alps.common.core;

import android.content.Context;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.Thread.UncaughtExceptionHandler;

public class CrashReportHandler implements UncaughtExceptionHandler {

	public static void attach(Context context) {
	    Thread.setDefaultUncaughtExceptionHandler(new CrashReportHandler(context));
	}

	private CrashReportHandler(Context context) {
	}

	@Override
	public void uncaughtException(Thread thread, Throwable e) {
		StringWriter stackTrace = new StringWriter();
		e.printStackTrace(new PrintWriter(stackTrace));
		System.exit(10);
	}
}